//
//  UIView+Saas.m
//  saas
//
//  Created by fangyibao on 2019/9/5.
//  Copyright © 2019 fangmao. All rights reserved.
//

#import "UIView+Saas.h"
#import <objc/runtime.h>
static NSString *LoadViewkey = @"LoadViewkey";
@implementation UIView (Saas)
+ (CGFloat)alignWidthWithPt:(CGFloat)pt
{
    return SCREEN_WIDTH*pt/IP6_WIDTH;
}
+ (CGFloat)alignHeightWithPt:(CGFloat)pt
{
    if (IPHONE_X) return pt;
    else return SCREEN_HEIGHT*pt/IP6_HEIGHT;
    
}
+ (CGFloat)alignWidthWith2Px:(CGFloat)px
{
    return [self alignWidthWithPt:px/2];
}
+ (CGFloat)alignHeightWith2Px:(CGFloat)px
{
    return [self alignHeightWithPt:px/2];
}
- (CGPoint)locationCurrentInwindow{
    CGPoint point = [self convertPoint:CGPointMake(0, 0) toView:[UIApplication sharedApplication].keyWindow];
    return point;
}
- (CGFloat)getLoadViewHeight{
    return 0;
}
- (UIView *)loadView{
    return objc_getAssociatedObject(self, &LoadViewkey);
}
- (void)setLoadView:(UIView *)loadView{
    objc_setAssociatedObject(self, &loadView, loadView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (UIViewController *)viewController {
    for(UIView* next = [self superview]; next; next = next.superview) {
        UIResponder* nextResponder = [next nextResponder];
        if([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController*)nextResponder;
        }
    }
    return nil;
}



@end
